<!--
 * @Author: coman
 * @LastEditors: coman
 * @Date: 2020-06-10 17:12:22
 * @motto: No pain,No gain
 * @LastEditTime: 2020-06-10 17:19:11
--> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 1、求1 + 2！ + 3！ + 4！....+20!的值
	- 2！ = 2 * 1
    - 3！ = 3 * 2 * 1 -->
    <script>
        var n =1;
        var sum = 0;
        for(i=1;i<=20;i++){
        for(j=1;j<=i;j++){
            n = n*j;
        }
         sum=sum+n;
        }
        console.log("1-20阶乘的和为:"+sum);
        
    </script>
</body>
</html>